package com.ruoyi.common.utils.html;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

/**
 * 把字符串转化成公式计算
 * @author bl
 */
public class ScriptEngineUtil {
    private  static ScriptEngine jse = new ScriptEngineManager().getEngineByName("JavaScript");


    /**
     * (1+(1*3+20)-1)<=2*4  false
     * @param formulaTxt
     * @return
     */
    public static boolean eval(String formulaTxt){
        try {
           return (boolean)jse.eval(formulaTxt);
        } catch (ScriptException e) {
            System.err.println("===>"+formulaTxt);
            throw new RuntimeException(e);
        }finally {
            return  false;
        }
    }
}
